package com.selenium.base;

import java.util.List;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;

public class DriverBase {
	WebDriver driver;
	public DriverBase(String browser) {
		this.driver = new SelectDriver().driverName(browser);
	}
	
	public void stop() {
		this.driver.close();
	}
	
	public void get(String url) {
		this.driver.get(url);
	}
	
	public void maxWindows() {
		this.driver.manage().window().maximize();
	}
	
	public WebElement findElement(By by) {
		WebElement element =(new WebDriverWait(this.driver,5)).until(ExpectedConditions.presenceOfElementLocated(by));
		return element;
	}
	
	public List<WebElement> findElements(By by){
		List<WebElement> elements = this.driver.findElements(by);
		return elements;
	}
	
	public WebElement findElement(WebElement element,By by) {
		return element.findElement(by);
	}
	
//	public void click(WebElement element) {
//		if(element!=null) {
//			element.click();
//		}else {
//			
//		}
//	}
//	
//	public void sendKeys(WebElement element,String value) {
//		if(element!=null) {
//			element.sendKeys(value);
//		}else {
//			
//		}
//	}
//	
//	public boolean assertElementIs(WebElement element) {
//		return element.isDisplayed();
//	}
	
	public void back() {
		this.driver.navigate().back();
	}
}
